package com.kcyu.sfherp.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kcyu.sfherp.service.NotificationService;
import com.kcyu.sfherp.utils.RestUtil;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;

@Service
public class NotificationServiceImpl implements NotificationService {

    @Override
    public boolean sendNotification(String title, String content) {
        HttpHeaders httpHeaders = new HttpHeaders();
        String s = RestUtil.doGetRequest("https://api.day.app/ZgosSQgpqREjhJcmTKZ9yD/" + title + "/" + content + "?isArchive=1", httpHeaders);
        JSONObject jsonObject = JSON.parseObject(s);
        if(jsonObject.getInteger("code") == 200) {
            return true;
        } else {
            return false;
        }
    }
}
